//
//  ViewController.m
//  PiPiPineapple
//
//  Created by 李晓东 on 17/10/27.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

#import "ViewController.h"
#import "UIImage+Extension.h"

#import "Style0ViewController.h"
#import "Style1ViewController.h"
#import "Style2ViewController.h"
#import "Style3ViewController.h"
#import "Style4ViewController.h"
#import "Style5ViewController.h"
#import "Style6ViewController.h"
#import "Style7ViewController.h"
#import "Style8ViewController.h"
#import "Style9ViewController.h"
#import "Style10ViewController.h"
#import "Style11ViewController.h"
#import "Style12ViewController.h"
#import "Style13ViewController.h"
#import "Style14ViewController.h"
#import "Style15ViewController.h"
#import "Style16ViewController.h"
#import "Style17ViewController.h"
#import "Style18ViewController.h"
#import "Style19ViewController.h"
#import "Style20ViewController.h"
#import "Style21ViewController.h"
#import "Style22ViewController.h"
#import "Style23ViewController.h"
#import "Style24ViewController.h"
#import "Style25ViewController.h"
#import "Style26ViewController.h"
#import "Style27ViewController.h"
#import "Style28ViewController.h"


#import "Style31ViewController.h"
#import <Masonry.h>
#import "ParentViewController.h"
#import "UIBarButtonItem+Category.h"

@interface ViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *toolsCollectionView;
@property (weak, nonatomic) IBOutlet UIImageView *backGroundView;

@end

@implementation ViewController

- (void)loadView{
    [super loadView];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(88, 88);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    [flowLayout setSectionInset:UIEdgeInsetsMake(10, 8, 0, 8)]; // collectionView的内边距,不影响内部 cell 的排列
    [flowLayout setMinimumLineSpacing:10];
    [flowLayout setMinimumInteritemSpacing:12];
    [self.toolsCollectionView setCollectionViewLayout:flowLayout];

    self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navigation_icon"]];// = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"navigationBar"]];
    [self.navigationController.navigationBar setContentMode:UIViewContentModeScaleAspectFit];
    
    UIImage *image = [UIImage imageNamed:@"honeBackground"];
    [self.backGroundView setContentMode:UIViewContentModeScaleAspectFill];
    [self.backGroundView setImage:image];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 32;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"li" forIndexPath:indexPath];
    [cell setAlpha:0.9];
    cell.layer.cornerRadius = 11;
    cell.layer.masksToBounds = YES;
    UIImage *image = [[UIImage imageNamed:[NSString stringWithFormat:@"%ld", indexPath.item]] rescaleImageToSize:cell.bounds.size];
    if (image != nil) {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
        [cell.contentView addSubview:imageView];
    }
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    [self initController:indexPath.item];
    
}

- (void)initController:(NSInteger)controllerId{
    BaseViewController *controller;
//    Style0TableViewController *controller0;// = [Style0TableViewController new];
    switch (controllerId) {
        case 0:
//            controller0 = [Style0TableViewController new];
            controller = [[Style0ViewController alloc]init];
            [controller setTitle:@"和值杀号"];
            
//            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 1:
            controller = [Style1ViewController new];
            break;
        case 2:
            controller = [Style2ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:2];
            [controller setTitle:@"AC 值"];
            break;
        case 3:
            controller = [Style3ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:3];
            break;
        case 4:
            controller = [Style4ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:4];
            break;
        case 5:
            controller = [Style5ViewController new];
            break;
        case 6:
            controller = [Style6ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:6];
            break;
        case 7:
            controller = [Style7ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:7];
            break;
        case 8:
            controller = [Style8ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:8];
            break;
        case 9:
            controller = [Style9ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:9];
            break;
        case 10:
            controller = [Style10ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:10];
            break;
        case 11:
            controller = [Style11ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:11];
            break;
        case 12:
            controller = [Style12ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:12];
            break;
        case 13:
            controller = [Style13ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:13];
            break;
        case 14:
            controller = [Style14ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:14];
            break;
        case 15:
            controller = [Style15ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:15];
            break;
        case 16:
            controller = [Style16ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:16];
            break;
        case 17:
            controller = [Style17ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:17];
            break;
        case 18:
            controller = [Style18ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:18];
            break;
        case 19:
            controller = [Style19ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:19];
            break;
        case 20:
            controller = [Style20ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:20];
            break;
        case 21:
            controller = [Style21ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:21];
            break;
        case 22:
            controller = [Style22ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:22];
            break;
        case 23:
            controller = [Style23ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:23];
            break;
        case 24:
            controller = [Style24ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:24];
            break;
        case 25:
            controller = [Style25ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:25];
            break;
        case 26:
            controller = [Style26ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:26];
            break;
        case 27:
            controller = [Style27ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:27];
            break;
        case 28:
            controller = [Style28ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:28];
            break;
        case 31:
            controller = [Style31ViewController new];
            controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:31];
            break;
//        case 3:
//            controller = [ParentViewController new];
//            break;
        default:
            break;
    }
    [self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil]];
    [self.navigationController pushViewController:controller animated:YES];
}

@end

